<template>
  <div
    v-if="!empty"
    v-infinite-scroll="load"
    :infinite-scroll-disabled="disabled"
    :infinite-scroll-distance="5"
    class="infinite-list-wrapper"
  >
    <slot name="header"></slot>
    <p v-if="loading" class="loading">Loading...</p>
    <!-- <p v-if="noMore">No more</p> -->
  </div>

  <div v-if="empty" class="emptylist">
    <img src="./empty.png" />
    <p>{{ tips }}</p>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { ElMessage } from 'element-plus'
const props = defineProps({
  loading: {
    type: Boolean,
    default: false,
  },
  disabled: {
    type: Boolean,
    default: false,
  },
  empty: {
    type: Boolean,
    default: false,
  },
  tips: {
    type: String,
    default: '暂无数据',
  },
})
const emits = defineEmits(['change'])
const load = () => {
  emits('change')
}
</script>

<style scoped>
/*滚动条样式*/
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-thumb {
  border-radius: 10px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.1);
}
.infinite-list-wrapper {
  height: 100%;
  width: 100%;
  flex: 1;
  overflow-y: auto;
}
.emptylist {
  height: 80%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.emptylist img {
  width: 150px;
  height: 150px;
  display: block;
  margin: 0 auto -10px;
}
.emptylist p {
  font-size: 18px;
  color: #a2abc7;
  text-align: center;
}
.loading {
  color: #999;
  height: calc(100% - 48px);
  overflow: hidden;
  display: flex;
  text-align: center;
  align-items: center;
  justify-content: center;
}
</style>
